Skip to content

fix: narrow write_multi_vars item types - #855

Merged
gijzelaerr merged 1 commit into
masterfrom
fix/redundant-write-multi-vars-cast
Sep 7, 2026
Merged

gijzelaerr merged 1 commit into
masterfrom
fix/redundant-write-multi-vars-cast

Conversation

@gijzelaerr

Copy link
Copy Markdown
Owner

Summary

  • replace the redundant list cast with per-item type narrowing
  • reject mixed S7DataItem and dictionary lists with a clear TypeError
  • keep compatibility with both the pinned mypy hook and newer mypy releases

Validation

  • uv run --frozen pre-commit run --all-files
  • pytest -q (1821 passed, 78 skipped)
  • mypy snap7/client.py
  • uv build --no-sources

@gijzelaerr
gijzelaerr requested review from nikteliy and removed request for nikteliy September 5, 2026 08:26
@gijzelaerr

Copy link
Copy Markdown
Owner Author

@bvanelli Given your recent S7CommPlus framing and multi-operation contributions, could you review this small write_multi_vars typing correction?

@bvanelli bvanelli left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Items still accepts dict[str, Any]. You could in theory make it stricter with a typedict. Right now, it still can fail with a KeyError, while the type hint is correct.

@gijzelaerr
gijzelaerr merged commit 4eaf21e into master Sep 7, 2026
44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants